package com.utils;

import org.apache.shiro.crypto.hash.SimpleHash;

public class MD5Util {

    /**把inputString加密*/
    public static String md5(String inputStr){
        return encodeByMD5(inputStr);
    }

    /**对字符串进行MD5编码*/
    private static String encodeByMD5(String originString){
        String hashAlgorithmName = "MD5";
        int hashIterations = 10;
        if (originString!=null) {
            try {
                SimpleHash result = new SimpleHash(hashAlgorithmName, originString, null, hashIterations);
                return result.toHex();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return null;
    }
}
